﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FirstPerson.Objects;
using Microsoft.Xna.Framework;
using ERF;
using FirstPerson.States;

namespace FirstPerson.Gametypes
{
    public struct GameData {
        public double startTime;
        public int randomSeed;
        public short killLimit, timeLimit;
        public string mapName;
        public GameTypeNumber gameTypeNumber;
    }
    public enum GameTypeNumber {
        DeathMatch,
        GhostMatch
    }
    public abstract class GameType
    {
        private short durationTime; //seconds
        protected TimeSpan startTime;
        protected ERFGame game;
        protected Random random;

        public TimeSpan StartTime
        {
            get { return startTime; }
        }

        public short DurationTime
        {
            get { return durationTime; }
            set { durationTime = value; }
        }

        public GameType(ERFGame game)
        {
            this.game = game;
            random = new Random();
        }

        public void ResetPlayer(Player player)
        {
            player.Position = PickSpawnpointPosition();
            player.Hp = 100;
            player.CurrentWeapon.Ammunition = 0; //e.Victim.CurrentWeapon.MaxAmmunition;
        }

        //method for determing the best position.
        public abstract Vector3 PickSpawnpointPosition();

        public abstract bool IsGameOver(GameTime startTime);

        public abstract int Score(Player player);

        public virtual void init(TimeSpan gameTime) {
            startTime = gameTime;
        }

        public WayPoint PickRandomSpawnPoint()
        {
            Map map = PlayingState.GetInstance(game.StateMachine).Map;

            return map.WayPoints[(int)(map.WayPoints.Length * random.NextDouble())];
        }
    }
}
